﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BasePlatformCommon;

namespace L9SubSet
{
	public partial class Form_NewOrSelect : Form
	{
		// 窗体可关闭标志
		private bool canCloseFlag = false;

		private string section = "NewOrSelect";			// 多语言文件配置节名称

		private string tip = "提示";						// MessageBox 题头

		/*****************************************************************************************/

		// 构造函数
		public Form_NewOrSelect()
		{
			InitializeComponent();

			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
			this.Font = new System.Drawing.Font(this.Font.Name, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134)));

			selectRadioButton.Checked = true;

			// 设置本地化语言
			if (LanguageOper.available == true)
			{
				setLanguageText();
			}
		}

		// 设置本地化语言
		public void setLanguageText()
		{
			if (LanguageOper.available == false)
			{
				return;
			}

			LanguageOper.SetCurrentCulture();

			tip = LanguageOper.ReadValue("Common", "tipStr");

			// 界面控件文字
			this.Text = LanguageOper.ReadValue(section, "newOrSelect.Text");
			switchGroupBox.Text = LanguageOper.ReadValue(section, "switchGroupBox.Text");
			newRadioButton.Text = LanguageOper.ReadValue(section, "newRadioButton.Text");
			selectRadioButton.Text = LanguageOper.ReadValue(section, "selectRadioButton.Text");
			okButton.Text = LanguageOper.ReadValue(section, "okButton.Text");
		}

		// 确定
		private void okButton_Click(object sender, EventArgs e)
		{
			if (newRadioButton.Checked)
			{
				this.DialogResult = DialogResult.OK;
			}
			
			if(selectRadioButton.Checked)
			{
				this.DialogResult = DialogResult.Yes;
			}

			canCloseFlag = true;
			this.Close();
		}

		// 右上角关闭按钮 - 结果为 Cancel
		private void Form_NewOrSelect_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (canCloseFlag == false)
			{
				this.DialogResult = DialogResult.Cancel;
			}
		}
	}
}
